#include <vector>
using namespace std;

void countsort(vector<int>& vc){
  int max = vc[0];
  int min = vc[0];
  for(int e:vc)
  {
    if(e < min)
    {
      min = e;
    }
    if(e > max)
    {
      max = e;
    }
  }
  int range = max - min + 1;
  vector<int> tmp;
  tmp.resize(range, 0);
  for(int e : vc)
  {
    ++tmp[e-min];
  }

  int i = 0;
  for(size_t j = 0; j<tmp.size(); ++j)
  {
    while(tmp[j]--)
    {
      vc[i++]  = j+min;  
    }
  }
}
